package com.xgggh.redpack.domain.rank;


import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import android.os.Parcel;
import android.os.Parcelable;

import com.xgggh.redpack.BR;
import com.xgggh.redpack.domain.redpack.Category;

import java.util.Date;

public class Rank  extends BaseObservable implements Parcelable {
    private Long id;

    private String accountId;

    private String accountName;

    private String headerUrl;
    /** 红包分类
     * {@link Category}
     */
    private int rank;

    private String rankName;


    private Date created;

    private Date updated;

    private Date deleted;

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    public String getRankName() {
        return rankName;
    }

    public void setRankName(String rankName) {
        this.rankName = rankName;
    }

    //DecimalFormat decimalFormat = new DecimalFormat("#.###");
    @Bindable
    public String getHeaderUrl() {
        return headerUrl;
    }

    public void setHeaderUrl(String headerUrl) {
        this.headerUrl = headerUrl;
        notifyPropertyChanged(BR.headerUrl);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getDeleted() {
        return deleted;
    }

    public void setDeleted(Date deleted) {
        this.deleted = deleted;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.accountId);
        dest.writeString(this.accountName);
        dest.writeString(this.headerUrl);
        dest.writeInt(this.rank);
        dest.writeString(this.rankName);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.deleted != null ? this.deleted.getTime() : -1);
    }

    public Rank() {
    }

    protected Rank(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.accountId = in.readString();
        this.accountName = in.readString();
        this.headerUrl = in.readString();
        this.rank = in.readInt();
        this.rankName = in.readString();
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpDeleted = in.readLong();
        this.deleted = tmpDeleted == -1 ? null : new Date(tmpDeleted);
    }

    public static final Creator<Rank> CREATOR = new Creator<Rank>() {
        @Override
        public Rank createFromParcel(Parcel source) {
            return new Rank(source);
        }

        @Override
        public Rank[] newArray(int size) {
            return new Rank[size];
        }
    };
}